package algotithm.leetcode.dp.test518;

/**
 * @author zhouyanxiang
 * @Date 2021-04-2021/4/8-23:58
 * @Title 518. 零钱兑换 II
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int amount = 5;
        int[] coins = {1,2,5};
        int change = solution.change(amount, coins);
        System.out.println(change);
    }

    public int change(int amount, int[] coins) {
        int[] dp = new int[amount + 1];
        dp[0] = 1;
        for (int coin : coins) {
            for (int i = coin; i < amount + 1; i++) {
                dp[i] = dp[i] + dp[i - coin] ;
            }
        }
        return dp[amount];
    }
}
